<template>
    <div>
        <div id="myMsg">
            {{msg}}
        </div>
        <button @click="changeMsg">修改内容</button>
    </div>

</template>

<script>
export default {
    data() {
        return {
            msg: 'hello'
        }
    },
    methods: {
        changeMsg() {
            this.msg = 'hello next tick'
            // 因为this.msg是一个异步处理，页面还没渲染完毕，立刻获取DOM元素导致
            console.log(document.querySelector('#myMsg').innerHTML) // hello
            // 解决方案
            this.$nextTick(function() {
                console.log(document.querySelector('#myMsg').innerHTML, '$nextTick')
            })
        }
    }
}
</script>